package com.ptu.mapper;

import com.github.pagehelper.Page;
import com.ptu.annotation.AutoFill;
import com.ptu.entity.Store;
import com.ptu.entity.Users;
import com.ptu.enumeration.OperationType;
import com.ptu.vo.StoreVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

@Mapper
public interface UsersMapper {

    /**
     * 根据用户名查询用户
     * @param username
     * @return
     */
    @Select("select * from users where username = #{username}")
    Users getByUsername(String username);

    /**
     * 用户注册
     * @param users
     */
    @Insert("insert into users (name, username, password, phone, sex, id_number, create_time) " +
            "values " +
            "(#{name}, #{username}, #{password}, #{phone}, #{sex}, #{idNumber}, #{createTime})")
    void insert(Users users);


    /**
     * 根据动态条件统计用户数量
     * @param map
     * @return
     */
    Integer countByMap(Map map);

    void update(Users users);

    /**
     * 根据id查询用户
     * @param id
     * @return
     */
    @Select("select * from users where id = #{id}")
    Users getById(Long id);
}
